# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time	: 2024/3/28 22:51
# @Author  : jize.liu
# @File	: 战损替换.py
# @声明	 : 版权由 刘继泽 所有,如有疑问，需要帮助请联系刘继泽
import maya.cmds as cmds
import os
locals = "D:/EP14/tihuan"

Chrs = ["Z:/AnimationSeries/A10/Assets/Chr/C0010GuiLi/RIG/A10_C0010GuiLi_RIG.ma" ]
for local_file in os.listdir (locals) :
	cmds.file (os.path.join (locals , local_file) , o = 1 , f = 1 , options = "v=0;" , ignoreVersion = 1 , typ = "mayaAscii")
	refFile_Node = []
	refNode = cmds.ls (type = "reference")
	refFiles = cmds.file (q = True , r = True)

	for refFile in refFiles :
		for Chr in Chrs :
			if Chr in cmds.file (q = True , r = True) :  # 检查字符文件是否在引用文件列表中
				Namespace = cmds.referenceQuery (Chr , namespace = True).split (":")[1]
				control_rig_node = Namespace + ":MJVis_CC"

				if cmds.objExists (control_rig_node) :
					#if cmds.attributeQuery ("ClothZhanSun" , node = control_rig_node , exists = True) :
					key = cmds.keyframe (control_rig_node, q = 1)
					if key :
						cmds.cutKey (control_rig_node, t = (key[0] , key[-1]))
					if cmds.attributeQuery ("Vis" , node = control_rig_node , exists = True) :
						cloth_attr = control_rig_node + ".Vis"
						cmds.setAttr (cloth_attr , 1)
					print("11111111111111111111")

	cmds.file (save = True , f = 1 )
	print("444444444444444")

